This page last changed on Aug 20, 2006 by aperepel.

The http connector can be used to send and receive mule events over http. It has a https connector used for http communication over ssl.

The javadoc for this transport provider can be found here. And the Source Xref can be found here

Http Connector Properties

See Tcp Provider for extra properties inherited by this connector.

Property Description Default Required
secure determines if the connector is using https. false No
proxyHostname If access to the web is through a proxy, this holds the server address.   No
proxyPort The port the proxy is configured on.   No
proxyUsername If the proxy requires authentication supply a username.   No
proxyPassword The password for the proxyUsername.   No
timeout The socket read timeout 5000 Yes
buffersize the buffer size used to read and write data 64*1024 Yes

Https Connector Properties

In addition to the above properties for the https connector you can also configure server and client certificate information. You will need to use the org.mule.providers.http.HttpsConnector in you Xml config file when configuring the connector.

Property Description Default Required
keyStore The location of the server keystore used to create a secure server socket .keystore Yes
keyPassword The password used to check integrity and unlock the key store   Yes (if keyStore is set)
storePassword The password for the server keystore   Yes
keyStoreType The type of keystore being used KeyStore.getDefaultType() Yes
keyManagerAlgorithm The Key Manager algorithm to use Depends on the JDK vendor, automatically discovered. Yes (if keyStore is set)
trustManagerAlgorithm The Trust Manager algorithm to use The same as keyManagerAlgorithm No
protocolHandler The value used for java.protocol.handler.pkgs Depends on the JDK vendor, automatically discovered. Yes
requireClientAuthentication Whether clients should be authenitcated when connecting true Yss
provider The sercurity provider object to register with the java Security manager Depends on the JDK vendor, automatically discovered. Yes (if keyStore is set)
clientKeyStore The location of the client keystore. This value is used to set javax.net.ssl.keyStore   Yes (if connector is being used by a client)
clientKeyStorePassword The password for the client keystore. This value is used to set javax.net.ssl.keyStorePassword   Yes (if clientKeyStore is set)
trustStore The location of the trust keystore. This value is used to set javax.net.ssl.trustStore (use clientKeystore) No
trustStorePassword The password for the trustStore. This value is used to set javax.net.ssl.trustStorePassword   Yes (if trustStore is set)
trustStoreType  The type of the truststore being used  KeyStore.getDefaultType() No 
explicitTrustStoreOnly Whether to use the clientKeyStore details as the trustStore details if a trustStore hasn't been explicitly set false No
keyManagerFactory The KeyManager factory to use. You woundn't normally set this as the KeyManagerFactory is determined based on the keyManagerAlgorithm   No
trustManagerFactory The TrustManager factory to use. Normally determined based on the trustManagerAlgorithm   No

Endpoints

Http endpoints are described as socket-based endpoints in the form of -

http://localhost:1234

To use https instead you need to change the endpoint URI protocol and set the necessary certificate information listed above -

https://localhost:1234

Unlike http endpoints you can't use https endpoints without having a https connector declared in your configuration. The https connector class is org.mule.providers.http.HttpsConnector.

Endpoint Properties

Any Http Response Header values can be added as endpoint properties. The following is a short list of some of the most usefull properties.

Property Description Default
http.status This specifies the status code of the reply, for example 200 would mean that the request was successfull 200
Content-Type This specifies the type of payload being sent in the Http Response text/plain
Location This property needs to be set if we what to make use of redirection, since here we define the address where the client will be redirected. See Http Redirection for more details.  

The following is a short example, depicting how to set these properties on the endpoint.

<endpoint address="http://localhost:8080/mine" synchronous="true">
	<properties>
		<property name="Content-Type" value="text/html"/>
		<property name="Location" value="http://mule.codehaus.org/"/>
		<property name="http.status" value="307"/>
	</properties>
</endpoint>

In this case, the type of the payload is that of text/html & we are also instructing the client to redirect ('http.status' being set to 307 = temporary redirection) to "http://mule.codehause.org".

Security

If you want to secure requests to your Http endpoint the http connector supports Http Basic/Digest authentication methods (as well as the Mule generic header authentication). If you want to configure Http Basic you need to configure a Security Endpoint Filter on a http endpoint.

<endpoint address="http://localhost:4567">
    <security-filter
        className="org.mule.extras.acegi.filters.http.HttpBasicAuthenticationFilter">
        <properties>
            <property name="realm" value="mule-realm"/>
        </properties>
    </security-filter>
</endpoint>

You'll need to configure a security manager on the Mule instance for this security filter to authenticate against. For information about security configuration options and examples see Mule Security.

For general information about Endpoint configuration see Mule Endpoints.

Sending Credentials

If you want to make a Http request that requires authentication, you can set the credentials on the endpoint -

http://user:[email protected]/secure

Polling Http Services

The Http transport supports Polling a Http URL, this is useful to grab periodic data from a page that changes of to invoke a REST service such as polling an Amazon Queue.

To configure the Http Polling receiver you must include a HttpConnector configuration in your MuleXml.

<connector name="pollingHttp" className="org.mule.providers.http.HttpConnector">
    <properties>
        <map name="serviceOverrides">
            <property name="message.receiver" value="
              org.mule.providers.http.PollingHttpMessageReceiver"/>
        </map>
    </properties>
</connector>

To use the connectore in you endpoints use -

http://anothercompany.com/services?connector=pollingHttp&pollingFrequency=30000

The equivilent explict enpoint configuration would look like -

<endpoint address="http://anothercompany.com/services" connector="pollingHttp">
    <properties>
        <property name="pollingFrequency" value="30000"/>
    </properties>
</endpoint>

Transformers

The following transformers are used by default for this connector unless a transformer is explicitly set on the provider.

Transformer Description

TODO
inbound, outbound and configuring response transformers

Handling HTTP Content-Type and Encoding

Sending HTTP (since Mule 1.3 RC2)

This is both for sending POST request bodies as a client and when returning a response body:

If we have a String, char[], Reader or similar:

  • If the endpoint has an encoding explicitly set, use that
  • Otherwise take it from the MuleMessage's property Content-Type
  • If none of these are set, use the MuleManager's configuration default.
  • For Content-Type, send the MuleMessage's property _Content-Type_but with the actual encoding set.
    (and splice it with the Content-Type, if need be)
  • If Content-Type property is set, send text/plain (or perhaps auto-detect XML?)

For binary content, encoding is not relevant. Content-Type is set as follows:

  • If the "Content-Type" property as set on the message, send that.
  • Send "application/octet-stream" as Content-Type if none is set on the message.

Receiving HTTP (since Mule 1.3 RC2)

This is both for receiving POST requests (as server) and when getting the response bodies as a client:

If Content-Type header is received:

  • Set on the message's property Content-Type
  • For text content (starts with "text/"), decode the payload to a String, using the specified encoding.
  • If no encoding is set, use ISO-8859-1 as is default in HTTP for text content, unless the encoding is explicitly on the endpoint.

If the Content-Type header is not present:

  • Don't set the "Content-Type" property.
  • Load as byte oriented payload.
Document generated by Confluence on Nov 27, 2006 10:27